package warehouse;

import java.util.ArrayList;
import java.util.Collection;
public class Gazebo extends Resource{

	public Gazebo(boolean disponibility, int partecipantCapacity, int gazeboNumber) {
		super(disponibility);
		this.partecipantCapacity = partecipantCapacity;
		this.gazeboNumber = gazeboNumber;
		tables = null;
	}
	
	public Gazebo(long id, boolean disponibility, int partecipantCapacity, int gazeboNumber) {
		super(id, disponibility);
		this.partecipantCapacity = partecipantCapacity;
		this.gazeboNumber = gazeboNumber;
		tables = null;
	}
	
	public Gazebo(long id, boolean disponibility, int partecipantCapacity, int gazeboNumber, Collection<Table> tables) {
		super(id, disponibility);
		this.partecipantCapacity = partecipantCapacity;
		this.gazeboNumber = gazeboNumber;
		this.tables = tables;
	}
	public int getPartecipantCapacity() {
		return partecipantCapacity;
	}
	public void setPartecipantCapacity(int partecipantCapacity) {
		this.partecipantCapacity = partecipantCapacity;
	}
	public int getGazeboNumber() {
		return gazeboNumber;
	}
	public void setGazeboNumber(int gazeboNumber) {
		this.gazeboNumber = gazeboNumber;
	}
	
	public Collection<Table> getTables() {
		return tables;
	}

	public void setTables(Collection<Table> tables) {
		int tot = 0;
		for(Table t : tables)
			tot += t.getSeatNumber();
		if(tot > partecipantCapacity)
			throw new IllegalStateException();
		this.tables = tables;
	}

	public void addTable(Table table){
		if(tables == null)
			tables = new ArrayList<Table>();
		else{
			int tot = table.getSeatNumber();
			for(Table t : tables)
				tot += t.getSeatNumber();
			if(tot > partecipantCapacity)
				throw new IllegalStateException();
		}
		tables.add(table);
	}
	private int partecipantCapacity;
	private int gazeboNumber;
	private Collection<Table> tables;
}
